package com.example.tnot.Teacher.MinePart.InternalFragment.notebook;

import android.annotation.SuppressLint;
import android.os.Bundle;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.tnot.R;
import com.example.tnot.Teacher.BaseFragment.BaseBackFragment;
import com.example.tnot.Teacher.MinePart.InternalFragment.notebook.ItemBean.folder;
import com.example.tnot.Teacher.MinePart.InternalFragment.notebook.adapter.FolderAdapter;

import java.util.ArrayList;
import java.util.List;

public class NoteBookFragment extends BaseBackFragment {

    private List<folder> data;


    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    ImageButton ib_back;
    RecyclerView rv_notebook;
    ImageView iv_notebookadd,iv_folderadd;
    private String mParam1;
    private String mParam2;

    public NoteBookFragment() {
    }

    public static NoteBookFragment newInstance(String param1, String param2) {
        NoteBookFragment fragment = new NoteBookFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @SuppressLint("MissingInflatedId")
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view =inflater.inflate(R.layout.mine_notebook_fragment, container, false);
        InitData();
        rv_notebook = view.findViewById(R.id.rv_notebook);
        rv_notebook.setLayoutManager(new LinearLayoutManager(getActivity()));
        rv_notebook.setAdapter(new FolderAdapter(data));

        iv_notebookadd = view.findViewById(R.id.iv_notebookadd);
        iv_notebookadd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        iv_folderadd = view.findViewById(R.id.iv_folderadd);
        iv_folderadd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        ib_back = view.findViewById(R.id.ib_back);
        ib_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                handleBackPressed();
            }
        });
        return view;
    }

    private void InitData() {
        data = new ArrayList<>();
        data.add(new folder(R.drawable.public_notebook, "公开笔记"));
        data.add(new folder(R.drawable.persion_notebook, "个人笔记"));
        data.add(new folder(R.drawable.class_notebook, "课堂笔记"));
    }
}